import time
def read2list(filename):
    file = open(filename, 'r')
    data = file.readlines()
    return data

b1 = read2list("b1_sorted.txt")
b2 = read2list("b2_reverse.txt")
b3 = read2list("b3_shuffle.txt")
d = time.time()
for i in range(len(b1)):
    a = 0
    for j in range(len(b1)-1):
        if b1[j] > b1[j+1]:
            b = b1[j]
            b1[j] = b1[j+1]
            b1[j+1] = b
            a = 1
    if a == 0:
        break
c = time.time()
print("Время 1:",round((c-d)*1000))
d = time.time()
for i in range(len(b2)):
    a = 0
    for j in range(len(b2)-1):
        if b2[j] > b2[j+1]:
            b = b2[j]
            b2[j] = b2[j+1]
            b2[j+1] = b
            a = 1
    if a == 0:
        break
c = time.time()
print("Время 2:",round((c-d)*1000))
d = time.time()
for i in range(len(b3)):
    a = 0
    for j in range(len(b3)-1):
        if b3[j] > b3[j+1]:
            b = b3[j]
            b3[j] = b3[j+1]
            b3[j+1] = b
            a = 1
    if a == 0:
        break
c = time.time()
print("Время 3:",round((c-d)*1000))
